<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>前锋图书管理系统</title>
    <link rel="stylesheet" href="/css/public.css"/>
    <link rel="stylesheet" href="/css/style.css"/>
    <link rel="stylesheet" href="/css/admineditpass.css"/>
    <link rel="stylesheet" href="/js/layui/css/layui.css"  media="all">
</head>
<style>
    html,body{
        width: 100%;
        height: 100%;
    }
    .homeWrap{
        width: 100%;height: 100%;
        padding-top: 76px;position: relative;box-sizing: border-box;overflow: hidden;
    }
    .homeWrap div{box-sizing: border-box;}
    .hide{
        display: none;
    }
    .detelebox button{
        width: 50px;
        height: 28px;
        margin-top: 10px;
        margin-left: 50px;
        display: inline-block;
        border: 1px solid #679e43;
        background: linear-gradient(to bottom,#baf076,#a2d866,#9cd055,#8dc838,#8bc93a);
        line-height: 28px;
        text-align: center;
        border-radius: 4px;
        font-weight: bold;
        color: #fff;
    }
    .passtitle{font-size: 16px;}
    .publicMian,.left{height: 100%;}
    .homeHeader{width: 100%; position: absolute;left: 0;top: 0;}
</style>
<body>
<div class="homeWrap">
    <div class="homeHeader">
        <!--头部-->
        <header class="publicHeader">
            <h1>前锋图书管理系统</h1>
            <div class="publicHeaderR">
                <p><span>下午好！</span><span style="color: #fff21b"> Admin</span> , 欢迎你！</p>
                <a href="/admin/index/signOut">退出</a>
            </div>
        </header>
        <!--时间-->
        <section class="publicTime">
            <span id="time">2015年1月1日 11:11  星期一</span>
        </section>
    </div>

    <!--主体内容-->
    <section class="publicMian">
        <div class="left">
            <h2 class="leftH2"><span class="span1"></span>功能列表 <span></span></h2>
            <nav>
                <ul class="list">
                    <li><a href="/admin/home/home">首页</a></li>
                    <li><a href="/admin/home/borrowingmanagement">借阅管理</a></li>
                    <li><a href="/admin/home/bookrecord">图书记录</a></li>
                    <li><a href="/admin/home/bookadd">图书添加</a></li>
                    <li><a href="/admin/scrollmember/scroll">滚屏</a></li>
                    <li><a href="/admin/scrollmember/member">会员管理</a></li>
                    <li id="active"><a href="/admin/home/editpass">修改密码</a></li>
                    <li><a href="/admin/home/groupbuy">团队来源</a></li>
                </ul>
            </nav>
        </div>
        <div class="right">
            <div class="location">
                <strong>你现在所在的位置是:</strong>
                <span>修改密码</span>
            </div>

            <!--主体内容-->
            <div class="recordWrap">
                <div class="record">
                    <div class="contentWrap">
                        <div class="newpass">
                            <span class="passtitle">原密码：&nbsp;&nbsp;&nbsp; </span>
                            <input type="password" name="password" class="oldpassinfo passinfo" placeholder="请输入原始密码">
                        </div>
                        <div class="newpass">
                            <span class="passtitle">新密码：&nbsp;&nbsp;&nbsp; </span>
                            <input type="password" name="password" class="newpassinfo passinfo" placeholder="请输入6-18位新密码">
                        </div>
                        <div class="newpass">
                            <span class="passtitle">重新输入：</span>
                            <input type="password" name="password" class="repassinfo passinfo" placeholder="请再次输入新密码">
                        </div>
                        <div class="primaryBtn">
                            <span class="determineBtn">确定</span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="pagePage" style="top: 800px;">
                <div class="page_control">
                    <div class="pagination"></div>
                </div>
            </div>
        </div>

    </section>
</div>

<script src="/js/jquery.js"></script>
<script src="/js/layer/layer.js"></script>
<script>
    $('.primaryBtn').click(function(){
        var oldpass = $('.oldpassinfo').val();
        var newpass = $('.newpassinfo').val();
        var repass = $('.repassinfo').val();
        var reg = /^[a-zA-Z0-9]{6,18}$/;
        if (oldpass=='') {
            layer.tips('原密码不能为空', '.oldpassinfo');
            return false;
        }else if (newpass=='') {
            layer.tips('密码不能为空', '.newpassinfo');
            return false;
        }else if (!reg.test(newpass)) {
            layer.tips('密码格式不正确', '.newpassinfo');
            return false;
        }else if (repass == '') {
            layer.tips('请再次输入密码', '.repassinfo');
            return false;
        }else if (newpass != repass) {
            layer.tips('两次输入的密码不一致', '.repassinfo');
            return false;
        }else{
            $.ajax({
                type:'POST',
                url:'/admin/Home/doeditpassword',
                data: {'oldpass':oldpass,'password':newpass},
                dataType:'json',
                success:function (data) {
                    console.log(data)
                    if(data==1){
                        layer.msg('修改成功！', {
                            icon: 1,
                            time: 1000
                        }, function () {
                            window.location.href = "/index/index/login";
                        });
                    }else{
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 1000
                        }, function () {

                        });
                    }
                },
                error:function (errorData) {
                    layer.alert('修改失败！', {icon: 2}, function () {
                        layer.closeAll();
                    })
                }
            })
        }
    })
</script>
</body>
</html>